<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:t="http://myfaces.apache.org/tomahawk"
				template="/pages/crud_template.xhtml"> 

	<ui:param name="crudBean" value="#{consultaConciliacaoAnaliticoBean}" />
	
	<ui:define name="saveStateObjectsDefined">
		<t:saveState value="#{crudBean.listaLocaisPagamentos}" />
	</ui:define>
	
	<ui:define name="requiredFieldsMessage">
		<h:outputText value="#{bundle.peloMenosUmDosCamposObrigatorios}" rendered="#{crudBean.searching}"/>
	</ui:define>
	
	<ui:define name="buttonItens">
		<!-- Painel dos botoes de pesquisa -->
		<h:panelGroup rendered="#{crudBean.searching}">
			<a4j:commandButton value="Pesquisar" actionListener="#{crudBean.pesquisar}" reRender="tblData"/>
			<h:outputText value=" "/>
			<h:commandButton value="Exportar Planilha" action="#{crudBean.exportExcel}" reRender="tblData"/>
			<h:outputText value=" "/>
			<h:commandButton value="Atualizar" actionListener="#{crudBean.atualizar}" reRender="formulario, tblData"/>
		</h:panelGroup>
	</ui:define>
	
	<ui:define name="content">
		<!-- Painel de Pesquisa - Inicio -->
		<h:panelGroup id="panelGroupDePesquisa" rendered="#{crudBean.searching}">
			<f:subview id="viewBusca">
				<table>
					<tr>
						<td class="tdCor" style="width: 660px;"><h:outputText value="Período da Baixa"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataBaixaInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" Até " />
							<rich:calendar value="#{crudBean.searchObject.filtro.dataBaixaFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="Período da Inclusão"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataInclusaoInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" Até " />
							<rich:calendar value="#{crudBean.searchObject.filtro.dataInclusaoFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="Período da Conciliação"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataConciliacaoInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" Até " />
							<rich:calendar value="#{crudBean.searchObject.filtro.dataConciliacaoFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Fatura"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.fatura}" size="30" maxlength="50" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Contrato"/> </td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.codigoContrato}" size="30" maxlength="20" onkeypress="soNumero(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Cliente"/> *</td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.codigoCliente}" size="30" maxlength="20" onkeypress="soNumero(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Nome do Cliente"/> *</td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.searchObject.nomeCliente}" size="60" maxlength="100" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Locais de Pagamento"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.localPagamentoVo.codigo}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaLocaisPagamentos}" />
    						</h:selectOneMenu>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="Flag de Conciliação"/></td>
						<td class="tdBranco">
							<table style="width: 200px;">
     		 					<tr>
     		 						<td>
										<h:selectOneRadio value="#{crudBean.searchObject.flagConciliado}">
										   <f:selectItem itemValue="T" itemLabel="Todos"/>   
										   <f:selectItem itemValue="S" itemLabel="Sim"/>   
										   <f:selectItem itemValue="N" itemLabel="Não"/>   
										</h:selectOneRadio>                                
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Pesquisa - Fim -->
	</ui:define>
	
	<ui:define name="list">
		<h:panelGroup id="panelGroupDeListagem" rendered="#{crudBean.searching}">
			<f:subview id="viewListagem">
				<rich:dataTable id="tblData" value="#{crudBean.searchResult}" binding="#{crudBean.tblData}" var="rst" style="width: 100%;" rowClasses="par,impar">
               		
               		<rich:column style="text-align: left;" sortBy="#{rst.localPagamentoVo.descricao}">
						<f:facet name="header">
							<h:outputText value="Local de Pagamento" />
						</f:facet>
						<h:outputText value="#{rst.localPagamentoVo.descricao}"/>
					</rich:column>
               		<rich:column style="text-align: center;" sortBy="#{rst.dataBaixa}">
						<f:facet name="header">
							<h:outputText value="Data da Baixa" />
						</f:facet>
						<h:outputText value="#{rst.dataBaixa}"/>
					</rich:column>
               		<rich:column style="text-align: right;" sortBy="#{rst.fatura}">
						<f:facet name="header">
							<h:outputText value="Fatura" />
						</f:facet>
						<h:outputText value="#{rst.fatura}"/>
					</rich:column>
               		<rich:column style="text-align: right;" sortBy="#{rst.codigoContrato}">
						<f:facet name="header">
							<h:outputText value="Contrato" />
						</f:facet>
						<h:outputText value="#{rst.codigoContrato}"/>
					</rich:column>
               		<rich:column style="text-align: right;" sortBy="#{rst.codigoCliente}">
						<f:facet name="header">
							<h:outputText value="Cliente" />
						</f:facet>
						<h:outputText value="#{rst.codigoCliente}"/>
					</rich:column>
               		<rich:column style="text-align: left;" sortBy="#{rst.nomeCliente}">
						<f:facet name="header">
							<h:outputText value="Nome do Cliente" />
						</f:facet>
						<h:outputText value="#{rst.nomeCliente}"/>
					</rich:column>
               		<rich:column style="text-align: right;" sortBy="#{rst.valorPagamento}">
						<f:facet name="header">
							<h:outputText value="Valor do Pagamento" />
						</f:facet>
						<h:outputText value="#{rst.valorPagamento}"/>
					</rich:column>
               		<rich:column style="text-align: center;" sortBy="#{rst.flagConciliado}">
						<f:facet name="header">
							<h:outputText value="Conciliado" />
						</f:facet>
						<h:outputText value="#{rst.flagConciliado}"/>
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<a4j:commandButton image="/imagens/desativar.bmp" style="border:white;" title="CONCILIAR" actionListener="#{crudBean.conciliar}" reRender="tblData" rendered="#{rst.flagConciliado.valor == 'NO'}"/> 
						<a4j:commandButton image="/imagens/ativar.bmp" style="border:white;" title="DESCONCILIAR" actionListener="#{crudBean.desconciliar}" reRender="tblData" rendered="#{rst.flagConciliado.valor == 'YES'}"/>
					</rich:column>
               		<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="" />
						</f:facet>
						<a4j:commandButton image="/imagens/lupa.png" style="border:white;" title="RAZÃO" actionListener="#{crudBean.exibirOcultarRazao}" reRender="tblData" /> 
					</rich:column>
					
					<rich:subTable id="subtblData" rendered="#{rst.exibirListaRazao}"
									onRowMouseOver="this.style.backgroundColor='#ffff33'"
			                        onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
									value="#{rst.listaRazaoAnalitico}" var="rstRazao">
						<rich:column colspan="4" style="text-align: center;">
							<f:facet name="header">
								<h:outputText value="" />
							</f:facet>
							<h:outputText value=""/>
						</rich:column>
						<rich:column style="text-align: center;" sortBy="#{rstRazao.dataBaixa}">
							<f:facet name="header">
								<h:outputText value="Data da Baixa" />
							</f:facet>
							<h:outputText value="#{rstRazao.dataBaixa}"/>
						</rich:column>
						<rich:column style="text-align: left;" sortBy="#{rstRazao.historico}">
							<f:facet name="header">
								<h:outputText value="Histórico" />
							</f:facet>
							<h:outputText value="#{rstRazao.historico}"/>
						</rich:column>
						<rich:column style="text-align: center;" sortBy="#{rstRazao.valorPagamento}">
							<f:facet name="header">
								<h:outputText value="Valor do Lançamento" />
							</f:facet>
							<h:outputText value="#{rstRazao.valorPagamento}"/>
						</rich:column>
						<rich:column colspan="3" style="text-align: center;">
							<f:facet name="header">
								<h:outputText value="" />
							</f:facet>
							<h:outputText value=""/>
						</rich:column>
				    </rich:subTable>
					
					<f:facet name="footer">
						<rich:columnGroup rendered="#{crudBean.searching}">
	                      	<rich:column colspan="6" style="text-align: right;">
					     		<h:outputText value="Total" />
			 		    	</rich:column>
	                       	<rich:column style="text-align: right;">
	                           	<h:outputText value="#{crudBean.searchObject.valorTotalPagamento}"/>
	                       	</rich:column>
	                       	<rich:column colspan="3" style="text-align: right;">
	                           	<h:outputText value=""/>
	                       	</rich:column>
                       	</rich:columnGroup>
                    </f:facet>
					
				</rich:dataTable>
			</f:subview>
		</h:panelGroup>
	</ui:define>
	
</ui:composition>